/*
 * This file is generated by jOOQ.
 */
package ru.ra_tech.garden_manager.database.schema.tables;


import java.time.OffsetDateTime;
import java.util.Arrays;
import java.util.List;
import java.util.function.Function;

import org.jooq.Field;
import org.jooq.ForeignKey;
import org.jooq.Function8;
import org.jooq.Identity;
import org.jooq.Index;
import org.jooq.Name;
import org.jooq.Record;
import org.jooq.Records;
import org.jooq.Row8;
import org.jooq.Schema;
import org.jooq.SelectField;
import org.jooq.Table;
import org.jooq.TableField;
import org.jooq.TableOptions;
import org.jooq.UniqueKey;
import org.jooq.impl.DSL;
import org.jooq.impl.SQLDataType;
import org.jooq.impl.TableImpl;

import ru.ra_tech.garden_manager.database.schema.Indexes;
import ru.ra_tech.garden_manager.database.schema.Keys;
import ru.ra_tech.garden_manager.database.schema.Public;
import ru.ra_tech.garden_manager.database.schema.tables.records.GardensRecord;


/**
 * This class is generated by jOOQ.
 */
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class Gardens extends TableImpl<GardensRecord> {

    private static final long serialVersionUID = 1L;

    /**
     * The reference instance of <code>public.gardens</code>
     */
    public static final Gardens GARDENS = new Gardens();

    /**
     * The class holding records for this type
     */
    @Override
    public Class<GardensRecord> getRecordType() {
        return GardensRecord.class;
    }

    /**
     * The column <code>public.gardens.id</code>.
     */
    public final TableField<GardensRecord, Long> ID = createField(DSL.name("id"), SQLDataType.BIGINT.nullable(false).identity(true), this, "");

    /**
     * The column <code>public.gardens.name</code>.
     */
    public final TableField<GardensRecord, String> NAME = createField(DSL.name("name"), SQLDataType.VARCHAR(255).nullable(false), this, "");

    /**
     * The column <code>public.gardens.address</code>.
     */
    public final TableField<GardensRecord, String> ADDRESS = createField(DSL.name("address"), SQLDataType.CLOB, this, "");

    /**
     * The column <code>public.gardens.owner</code>.
     */
    public final TableField<GardensRecord, Long> OWNER = createField(DSL.name("owner"), SQLDataType.BIGINT.nullable(false), this, "");

    /**
     * The column <code>public.gardens.deleted</code>.
     */
    public final TableField<GardensRecord, Boolean> DELETED = createField(DSL.name("deleted"), SQLDataType.BOOLEAN.nullable(false).defaultValue(DSL.field(DSL.raw("false"), SQLDataType.BOOLEAN)), this, "");

    /**
     * The column <code>public.gardens.createdAt</code>.
     */
    public final TableField<GardensRecord, OffsetDateTime> CREATEDAT = createField(DSL.name("createdAt"), SQLDataType.TIMESTAMPWITHTIMEZONE(6).nullable(false).defaultValue(DSL.field(DSL.raw("now()"), SQLDataType.TIMESTAMPWITHTIMEZONE)), this, "");

    /**
     * The column <code>public.gardens.updatedAt</code>.
     */
    public final TableField<GardensRecord, OffsetDateTime> UPDATEDAT = createField(DSL.name("updatedAt"), SQLDataType.TIMESTAMPWITHTIMEZONE(6), this, "");

    /**
     * The column <code>public.gardens.deletedAt</code>.
     */
    public final TableField<GardensRecord, OffsetDateTime> DELETEDAT = createField(DSL.name("deletedAt"), SQLDataType.TIMESTAMPWITHTIMEZONE(6), this, "");

    private Gardens(Name alias, Table<GardensRecord> aliased) {
        this(alias, aliased, null);
    }

    private Gardens(Name alias, Table<GardensRecord> aliased, Field<?>[] parameters) {
        super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.table());
    }

    /**
     * Create an aliased <code>public.gardens</code> table reference
     */
    public Gardens(String alias) {
        this(DSL.name(alias), GARDENS);
    }

    /**
     * Create an aliased <code>public.gardens</code> table reference
     */
    public Gardens(Name alias) {
        this(alias, GARDENS);
    }

    /**
     * Create a <code>public.gardens</code> table reference
     */
    public Gardens() {
        this(DSL.name("gardens"), null);
    }

    public <O extends Record> Gardens(Table<O> child, ForeignKey<O, GardensRecord> key) {
        super(child, key, GARDENS);
    }

    @Override
    public Schema getSchema() {
        return aliased() ? null : Public.PUBLIC;
    }

    @Override
    public List<Index> getIndexes() {
        return Arrays.asList(Indexes.GARDENS_OWNER_INDEX);
    }

    @Override
    public Identity<GardensRecord, Long> getIdentity() {
        return (Identity<GardensRecord, Long>) super.getIdentity();
    }

    @Override
    public UniqueKey<GardensRecord> getPrimaryKey() {
        return Keys.GARDENS_PKEY;
    }

    @Override
    public Gardens as(String alias) {
        return new Gardens(DSL.name(alias), this);
    }

    @Override
    public Gardens as(Name alias) {
        return new Gardens(alias, this);
    }

    @Override
    public Gardens as(Table<?> alias) {
        return new Gardens(alias.getQualifiedName(), this);
    }

    /**
     * Rename this table
     */
    @Override
    public Gardens rename(String name) {
        return new Gardens(DSL.name(name), null);
    }

    /**
     * Rename this table
     */
    @Override
    public Gardens rename(Name name) {
        return new Gardens(name, null);
    }

    /**
     * Rename this table
     */
    @Override
    public Gardens rename(Table<?> name) {
        return new Gardens(name.getQualifiedName(), null);
    }

    // -------------------------------------------------------------------------
    // Row8 type methods
    // -------------------------------------------------------------------------

    @Override
    public Row8<Long, String, String, Long, Boolean, OffsetDateTime, OffsetDateTime, OffsetDateTime> fieldsRow() {
        return (Row8) super.fieldsRow();
    }

    /**
     * Convenience mapping calling {@link SelectField#convertFrom(Function)}.
     */
    public <U> SelectField<U> mapping(Function8<? super Long, ? super String, ? super String, ? super Long, ? super Boolean, ? super OffsetDateTime, ? super OffsetDateTime, ? super OffsetDateTime, ? extends U> from) {
        return convertFrom(Records.mapping(from));
    }

    /**
     * Convenience mapping calling {@link SelectField#convertFrom(Class,
     * Function)}.
     */
    public <U> SelectField<U> mapping(Class<U> toType, Function8<? super Long, ? super String, ? super String, ? super Long, ? super Boolean, ? super OffsetDateTime, ? super OffsetDateTime, ? super OffsetDateTime, ? extends U> from) {
        return convertFrom(toType, Records.mapping(from));
    }
}
